package com.prize.config;

import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.context.request.async.DeferredResult;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;


/**
 * Swagger2配置类
 */
@Configuration
@EnableSwagger2
@EnableKnife4j
public class Swagger2Config {

    //@Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .useDefaultResponseMessages(false)
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.prize"))
                .paths(PathSelectors.any())
                .build().groupName("科技有限公司").pathMapping("/")
                .forCodeGeneration(Boolean.TRUE)
                .forCodeGeneration(true)
                .enable(true)
                .genericModelSubstitutes(DeferredResult.class);
    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("抽奖管理平台-会员管理服务-前后端对接文档")
                .description("本文档详细描述了抽奖管理平台系统各接口的入参与出参信息")
                .termsOfServiceUrl("http://127.0.0.1:60000/doc.html")
                .contact(new Contact("开发一组",
                        "", ""))
                .version("V1.0.0版本")
                .build();
    }
}
